#include "Material.h"

#include <sstream>

Material::Material()
: m_sName("Unknown")
{

}

const char *Material::getName() const
{
	return this->m_sName.c_str();
}

void Material::setName(const string &_sName)
{
	this->m_sName = _sName;
}

const char *Material::reportMaterialList(const List<Material*> &_vMaterialList)
{
	if(_vMaterialList.size() <= 0)
	{
		return "Empty";
	}

	stringstream ssReport;

	Iterator<Material*> iterator = _vMaterialList.getIterator();
	while(iterator.hasNext())
	{
		ssReport << " - " << iterator.next() << endl;
	}
	
	char * sReport = new char[ssReport.str().size()+1];
	strcpy_s(sReport, ssReport.str().size()+1, ssReport.str().c_str());

	return sReport;
}

ostream &Material::operator<<(ostream &_os)
{
	_os << this->getName();
	return _os;
}

ostream &operator<<(ostream &_os, const Material &_oMaterial)
{
	_os << _oMaterial.getName();
	return _os;
}

ostream &operator<<(ostream &_os, const Material *_pMaterial)
{
	if(_pMaterial == 0)
	{
		_os << "null";
	}
	else
	{
		_os << _pMaterial->getName();
	}
	return _os;
}